#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

vector<int> trim0(vector<int> A) {
    while (A.size() > 1 && A[A.size() - 1] == 0) {
        A.pop_back();
    }
    return A;
}

vector<int> reverse(vector<int> A) {
    vector<int> B;
    for (int i = A.size() - 1; i > -1; i--) {
        B.push_back(A[i]);
    }
    return B;
}

vector<int> div(vector<int> A, int b, int *r) {
    vector<int> C;
    vector<int> R;
    *r = 0;
    for (int i = 0; i < A.size(); ++i) {
        *r = *r * 10 + A[i];
        int cc = *r / b;
        C.push_back(cc);
        *r = (*r % b);
    }
    return reverse(trim0(reverse(C)));
}

int main() {
    string a;
    int b;
    cin >> a >> b;

    vector<int> A;
    for (int i = 0; i < a.size(); i++) {
        A.push_back(a[i] - '0');
    }
    int r = 0;
    vector<int> C = div(A, b, &r);

    for (int i = 0; i < C.size(); ++i) {
        printf("%d", C[i]);
    }
    printf("\n%d\n", r);
    return 0;
}
